<template>
	<view>
		<u-navbar title="添加音频" back-icon-color="#fff" title-color="#fff" :background="background"></u-navbar>
		<view class="flex-col page items-center">
			<view class="flex-col group">
				<view class="flex-col section" :style="{backgroundImage: 'url(' + commonData.addAudioData.addTextBg +')'}">
					<text class="self-start text_2">您可以在录音时阅读此内容...</text>
					<view class="flex-col items-start self-stretch mt-23-5">
						<textarea :value="content" placeholder="粘贴你的内容" placeholder-class="font" class=" textarea-class"
							maxlength="1000" />
					</view>
				</view>

			</view>
			<!-- v-if="audioUrlTemp != ''" -->
			<view class="flex-col section_2 mt-29" v-if="audioUrlTemp != ''">
				<view class="flex-row justify-center items-center">
					<image @click="playAudio" v-if="playStatus == 'pause'" class="image_3"
						src="https://terminator.axu9.com/images/paly-icon.png" />
					<image @click="playAudio" v-if="playStatus == 'play'" class="image_3"
						src="https://terminator.axu9.com/images/pause-audio.png" />
				</view>
				<image v-if="playStatus == 'pause'" class="image_4 mt-23"
					src="https://terminator.axu9.com/images/audip-yinpin.png" />
				<image v-if="playStatus == 'play'" class="image_4 mt-23"
					src="https://terminator.axu9.com/images/paly-icon-gif.gif" />
			</view>
			<!-- <button @tap="test">确定</button> -->
			<!-- <view class="bottom flex-col items-center"> -->
			<!-- <view class="flex-row">
						<button @tap="startRecord">开始录音</button>
						<button @tap="pauseRecord">暂停录音</button>
						<button @tap="resumRecord">继续录音</button>
						<button @tap="endRecord">停止录音</button>
						<button @tap="playVoice">播放录音</button>
					</view> -->
			<view class="flex-col group_2 mt-23">
				<!-- <view class="flex-row  items-center self-stretch"
						:class="recordStatus == '已暂停' ? 'justify-between' : 'justify-center'">
						
						<image v-if="recordStatus == '已暂停'" class="image_6" src="https://terminator.axu9.com/images/addaudio-delicon.png" />
						<image v-if="recordStatus == '未开始' || recordStatus == '已暂停'" @click="startRecord" class="image_5"
							src="https://terminator.axu9.com/images/start-record.png" />
						<image v-if="recordStatus == '录音中'" @click="endRecord" class="image_5"
							src="https://terminator.axu9.com/images/record-pause.png" />
						<image v-if="recordStatus == '已暂停'" @click="finish" class="image_6 image_7"
							src="https://terminator.axu9.com/images/addaudio-ok.png" />
					</view> -->
				<view class="flex-row  items-center self-stretch"
					:class="recordStatus == '已暂停' ? 'justify-between' : 'justify-center'">
					<!-- <view class="" style="color: #fff;">
							{{recordStatus}}--{{isStop}}--{{isOk}}
						</view> -->


					<image @click="delAudio" v-if="recordStatus == '已暂停' || recordStatus == '已停止'" class="image_6"
						src="https://terminator.axu9.com/images/addaudio-delicon.png" />
					<image v-if="recordStatus == '未开始'" @click="startRecord" class="image_5"
						:src="commonData.addAudioData.startRecord" />
					<image v-if="recordStatus == '已暂停'" @click="resumRecord" class="image_5"
						:src="commonData.addAudioData.startRecord" />
					<image v-if="recordStatus == '录音中'" @click="pauseRecord" class="image_5"
						:src="commonData.addAudioData.recordPause" />

					<!-- <image v-if="recordStatus == '已暂停' && isStop == false" @click="finish" class="image_6 image_7"
							src="https://terminator.axu9.com/images/addaudio-ok.png" />
						<image v-if="recordStatus == '已暂停' && isStop == true" @click="addAudio" class="image_6 image_7"
							src="https://terminator.axu9.com/images/add-record-icon.png" /> -->
					<image v-if="recordStatus == '已暂停' && isOk == false" @click="finish" class="image_6 image_7"
						:src="commonData.addAudioData.addaudioOk" />
					<image v-if="recordStatus == '已暂停' && isOk == true" @click="addAudio" class="image_6 image_7"
						:src="commonData.addAudioData.addRecordIcon" />
				</view>
				<text class="self-center font_1 text_4 mt-12-5" v-if="recordStatus == '未开始'">点击开始</text>
				<text class="self-center font_1 text_4 mt-12-5" v-if="recordStatus == '已暂停'">点击继续</text>
				<text class="self-center font_1 text_4 mt-12-5" v-if="recordStatus == '录音中'">点击暂停</text>
			</view>
			<!-- <view @click="submit" class="flex-col justify-start items-center text-wrapper"><text class="font">确定</text>
				</view> -->
			<!-- </view> -->
		</view>

		<!-- 设置标题弹窗 -->
		<audioTitlePop ref="audiotitle" @submit="submit" :isLoading="isLoading"></audioTitlePop>
		<!-- <u-popup v-model="showPop" mode="center" :custom-style="customStyle" :mask-custom-style="maskCustomStyle">
			<view class="flex-col flex-1 popup ml-7-5">
				<text class="self-center title">添加标题</text>
				<view class="flex-col self-stretch mt-16-5">
					<view class="input-wrap">
						<input type="text" v-model="audioTitle" placeholder="请输入音频标题" class="input-class"
							placeholder-class="input-placeholder" />
					</view>
					<view class="flex-row bottom-btn">

						<view @click="submit" class="flex-col justify-start items-center noagree-btn">
							<text class="font-agree">确定</text>
						</view>
					</view>
				</view>
			</view>
		</u-popup> -->


	</view>
</template>

<script>
	import commonData from '@/common/js/data.js';
	// const recorderManager = uni.getRecorderManager();
	let recorderManager;
	const innerAudioContext = uni.createInnerAudioContext();

	innerAudioContext.autoplay = false;
	innerAudioContext.volume = 1;
	import {
		prompt,
		tapeFile,
		myYinseFileup,
		morenShengYin,
		MinorlanguagesTiqu//提取音色
	} from "@/api/audio.js"
	import audioTitlePop from "../../components/audioTitlePop"
	export default {
		components: {
			audioTitlePop
		},
		data() {
			return {
				content: '',
				audioUrlTemp: '', //临时音频路径
				audioUrl: '', //传到服务器上的音频路径
				// playStatus: false, //true播放中 false暂停
				// recordStatus: false, //true录音中 false录音暂停

				recordStatus: '未开始', // '未开始': 未开始录音; '录音中':录音中; '已暂停':录音暂停
				duration: "0:00",
				showPop: false,
				maskCustomStyle: {
					background: 'rgba(0, 0, 0, 1)'
				},
				audioTitle: '', //音频标题
				videoPath: '', //视频路径
				addType: 1, //跳转类型 1音视频合成 2添加音频
				type: 1, //添加语音类型 1生成提示文字 2不生成
				permisionState: false,
				isStop: false,
				playStatus: 'pause',
				innerAudioContext: null,
				toAddType: 1, //2 AI录制
				clickoption: 1, //
				toOptionType: 1, //
				isOk: false, //是否结束
				isLoading: false, //是否加载中
				audioId: '', //音频id
				timbreId: '', //音色id
				commonData: {},
				isxiao:false,//是否为小语种
				list_id:""
			}
		},
		onLoad(options) {
			this.commonData = commonData;
			console.log(options, 'options')
			this.toAddType = options.toAddType ? options.toAddType : 1;
			// this.videoPath = options.videoPath ? options.videoPath : '';
			this.clickoption = options.clickoption ? options.clickoption : 1;
			this.toOptionType = options.toOptionType ? options.toOptionType : 1;

			this.content = options.wenan ? options.wenan : '';
			// this.type = options.type ? options.type : 1;
			this.videoPath = options.videoPath ? options.videoPath : '';
			this.timbreId = options.timbreId ? options.timbreId : '';
			// this.addType = options.addType ? options.addType : 1;
			// if(this.type == 1){
			// 	this.getText();
			// }
			this.isxiao = options.isxiao == true || options.isxiao == 'true' ? options.isxiao : false
			this.list_id = options.listid ? options.listid : ""
			if (this.toAddType != 2 && this.toAddType != 5 && this.toAddType != 4) {
				this.getText();
			}
			recorderManager = uni.getRecorderManager();
			recorderManager.duration = 600000; //时长10分钟
			// recorderManager.sampleRate = 44100;//采样率
			// recorderManager.encodeBitRate = 64000;//采样位数
			recorderManager.sampleRate = 32000; //采样率
			recorderManager.encodeBitRate = 92000; //采样位数
			let self = this;

			recorderManager.onStart(function(res) {
				// console.log('recorder start' + JSON.stringify(res));
				self.isOk = false;
				console.log(res, '开始录音1')
				self.recordStatus = '录音中';
				console.log(self.recordStatus, 'self.recordStatus')
			});
			recorderManager.onPause(function(res) {
				// console.log('recorder start' + JSON.stringify(res));
				console.log(res, '暂停录音1')
				self.recordStatus = '已暂停';
				// console.log(self.recordStatus,'self.recordStatus')
			});

			recorderManager.onResume(function(res) {
				// console.log('recorder start' + JSON.stringify(res));
				console.log(res, '继续录音1')
				self.recordStatus = '录音中';
				// console.log(self.recordStatus,'self.recordStatus')
			});

			recorderManager.onStop(function(res) {
				console.log('recorder stop' + JSON.stringify(res));
				// self.showPop = true;
				console.log(self.isOk, 'isokkkk')
				if (self.isOk) {
					self.audioUrlTemp = res.tempFilePath;
					self.isStop = true;
				} else {
					self.audioUrlTemp = '';
					self.isStop = false;
				}

				console.log(self.audioUrlTemp, 'self.audioUrlTemp')

				console.log('recorder stop' + JSON.stringify(res));
				self.voicePath = res.tempFilePath;
				// self.uploadAudio(self.audioUrlTemp);


				// self.$uploadAudio(res.tempFilePath).then(res => {
				// 	console.log(res, 'uploadImg')
				// 	// this.cardimg = res.data.img
				// 	// self.audioName = res.name


				// })
			});
			recorderManager.onFrameRecorded(function(res) {
				console.log('recorder onFrameRecorded' + JSON.stringify(res));
			});
		},
		created() {
			this.contextInit();
		},

		// beforeDestroy() {
		// 	console.log('离开')
		// 	this.innerAudioContext.destroy();
		// },
		onUnload() {
			if (recorderManager) {
				console.log('离开')
				recorderManager.stop();
				recorderManager = null;;
			}
		},
		onHide() {
			if (recorderManager) {
				console.log('隐藏')
				recorderManager.stop();
				recorderManager = null;
				this.innerAudioContext.stop();
				this.innerAudioContext.destroy();
			}
		},
		//  beforeDestroy() {
		//  	console.log('离开1')
		// recorderManager.stop();
		//  	recorderManager.destroy();

		//  },
		// onShareAppMessage: function (res) {},//分享好友
		// onShareTimeline(){},//分享朋友圈
		methods: {
			test() {
				this.$refs.audiotitle.open();
			},
			delAudio() {
				this.isOk = false;
				recorderManager.stop();
				this.recordStatus = '未开始';
				this.audioUrlTemp = ''; //临时音频路径
				this.audioUrl = ''; //传到服务器上的音频路径
			},
			addAudio() {
				this.playStatus = "pause"
				this.innerAudioContext.stop()
				if(this.isxiao){
					this.uplodyinse(this.audioUrlTemp)
					return
				}
				
				// this.showPop = true;
				this.$refs.audiotitle.open();
			},
			// 音色上传
			uplodyinse(filePath){
				var _this = this;
				_this.$upload(filePath).then(res => {
					if (res.data.errno == 1) {
							this.getTiqu( res.data.img)
					} else {
						uni.hideLoading()
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				}).catch(err => {
					console.log(err, 'err')
					uni.showToast({
						title: '出错了',
						icon: 'none'
					})
				})
			},
			tiaozhuan() {
				if (this.toAddType == 1) {
					uni.switchTab({
						url: '/pages/mine/index?current=1'
					})
				} else if (this.toAddType == 2) {
					if (this.toOptionType == 1) {
						uni.reLaunch({
							url: '/pages/create/index?videoPath=' + this.videoPath + '&audioUrl=' + this.audioUrl +
								'&audioTitle=' + this.audioTitle
						})
					} else if (this.toOptionType == 2) {
						uni.redirectTo({
							url: '/pagesHome/audioList/index?videoPath=' + this.videoPath
						})
					} else if (this.toOptionType == 3) {
						uni.reLaunch({
							url: '/pagesMine/worksLibrary/index?current=1'
						})
					}
				} else if (this.toAddType == 3) {
					uni.redirectTo({
						url: '/pagesCreate/addAudioByText/index?videoPath=' + this.videoPath + '&clickoption=' +
							this.clickoption + '&toOptionType=' + this.toOptionType
					})
				} else if (this.toAddType == 4) {
					if (this.toOptionType == 1) {
						uni.reLaunch({
							url: '/pages/create/index?videoPath=' + this.videoPath + '&audioUrl=' + this.audioUrl +
								'&audioTitle=' + this.audioTitle
						})
					} else if (this.toOptionType == 2) {
						uni.redirectTo({
							url: '/pagesHome/audioList/index?videoPath=' + this.videoPath
						})
					} else if (this.toOptionType == 3) {
						uni.reLaunch({
							url: '/pagesMine/worksLibrary/index?current=1'
						})
					}
				} else if (this.toAddType == 5) {
					if (this.toOptionType == 1) {
						uni.reLaunch({
							url: '/pages/create/index?videoPath=' + this.videoPath + '&audioUrl=' + this.audioUrl +
								'&audioTitle=' + this.audioTitle
						})
					} else if (this.toOptionType == 2) {
						uni.redirectTo({
							url: '/pagesHome/audioList/index?videoPath=' + this.videoPath
						})
					} else if (this.toOptionType == 3) {
						uni.reLaunch({
							url: '/pagesMine/worksLibrary/index?current=1'
						})
					}
				}
			},
			contextInit() {
				let that = this;
				var innerAudioContext = uni.createInnerAudioContext();
				innerAudioContext.autoplay = false;

				innerAudioContext.loop = false;
				innerAudioContext.onPlay(() => {
					that.playStatus = 'play';
					console.log('开始播放', that.audioIndex);
					uni.hideLoading();
				});
				innerAudioContext.onPause(() => {
					that.playStatus = 'pause';
					console.log('暂停播放');
					uni.hideLoading();
				});
				innerAudioContext.onTimeUpdate(function() {
					// that.audioTimeUpdate = sToHs(Math.floor(innerAudioContext.currentTime));
				});
				innerAudioContext.onEnded(function() {
					that.playStatus = 'pause';
					console.log('暂停播放');
					uni.hideLoading();
				});

				innerAudioContext.onError((res) => {
					console.log(res, 'error')
					that.playStatus = 'pause';
					uni.hideLoading();
					uni.showToast({
						title: '加载失败',
						icon: 'none'
					})
				});
				that.innerAudioContext = innerAudioContext
			},
			playAudio() {
				if (this.playStatus == 'pause') {
					this.innerAudioContext.src = this.audioUrlTemp;
					this.innerAudioContext.play()
				} else {
					this.innerAudioContext.pause()
				}
			},
			checkPermission() {

				uni.authorize({
					scope: 'scope.record',
					success: () => {
						this.permisionState = true;
					},
					fail() {
						uni.showToast({
							title: '请授权使用录音',
							icon: 'none'
						});
					}
				});

			},
			pauseRecord() {
				console.log('暂停录音');
				recorderManager.pause();
			},
			resumRecord() {
				console.log('继续录音');
				recorderManager.resume();
			},
			startRecord() {
				console.log('开始录音', this.recordStatus);
				this.$isAuthorize('scope.record',{title: '录音权限请求',content: '为了使用录音功能，我们需要您的麦克风权限。'}).then(res=> {
					console.log(res,'授权')
					if(res == true){
						// 已授权
						recorderManager.start();
					}else {
						// 未授权打开授权
					}
				})
				// if(this.recordStatus == '未开始'){
				// 		recorderManager.start();
				// 	}else {
				// 		recorderManager.resume();
				// 	}
				
			},
			endRecord() {
				console.log('录音结束');
				recorderManager.stop();
				// recorderManager.pause();
			},
			playVoice() {
				console.log('播放录音');

				if (this.voicePath) {
					innerAudioContext.src = this.voicePath;
					innerAudioContext.play();
				}
			},
			// startRecord() {
			// 	if (!this.permisionState) {
			// 		this.checkPermission();
			// 		return;
			// 	}
			// 	console.log('开始录音');
			// 	if(this.recordStatus == '未开始'){
			// 		recorderManager.start();
			// 	}else {
			// 		recorderManager.resume();
			// 	}

			// },
			// endRecord() {
			// 	console.log('录音结束');
			// 	// recorderManager.stop();
			// 	recorderManager.pause();
			// },
			// playVoice() {
			// 	console.log('播放录音');

			// 	if (this.audioUrlTemp) {
			// 		innerAudioContext.src = this.audioUrlTemp;
			// 		innerAudioContext.play();
			// 	}
			// },
			// 制作音色提示文字
			getText() {
				prompt().then(res => {
					console.log(res, 'eeeeee')
					this.content = res.data;
				}).catch(err => {

				})
			},
			finish() {
				this.isOk = true;
				recorderManager.stop();

			},
			submit(data) {
				this.audioTitle = data
				if (this.audioTitle == '') {
					uni.showToast({
						title: '音频标题不能为空',
						icon: 'none'
					})
					return
				}
				// this.tiaozhuan();
				// return
				this.uploadAudio();

			},
			// submit() {
			// 	// this.showPop = false;
			// 	if(this.audioTitle == ''){
			// 		uni.showToast({
			// 			title: '音频标题不能为空',
			// 			icon: 'none'
			// 		})
			// 		return
			// 	}
			// 	this.uploadAudio();


			// },
			addTimbreToMine() {
				uni.showLoading({
					title: '上传中'
				})

				myYinseFileup({
					// uid: uni.getStorageSync("userId"),
					id: this.timbreId,
					title: this.audioTitle,
					mp3: this.audioUrl
					// title: 'hhh',
					// mp3: "https://audiovideo.axa2.com/zmp366c401d173f686666.mp3"
				}).then(res => {
					console.log(res, 'ressss')
					this.isLoading = false;
					uni.hideLoading();
					if (res.errno == 0) {
						console.log(this.videoPath, 'this.videoPath')
						if (this.toAddType == 1) {
							uni.switchTab({
								url: '/pages/mine/index?current=1'
							})
						} else if (this.toAddType == 2) {
							if (this.toOptionType == 1) {
								uni.reLaunch({
									url: '/pages/create/index?videoPath=' + this.videoPath + '&audioUrl=' +
										this.audioUrl + '&audioTitle=' + this.audioTitle
								})
							} else if (this.toOptionType == 2) {
								uni.redirectTo({
									url: '/pagesHome/audioList/index?videoPath=' + this.videoPath
								})
							} else if (this.toOptionType == 3) {
								uni.reLaunch({
									url: '/pagesMine/worksLibrary/index?current=1'
								})
							}
						} else if (this.toAddType == 3) {
							uni.redirectTo({
								url: '/pagesCreate/addAudioByText/index?videoPath=' + this.videoPath +
									'&clickoption=' + this.clickoption + '&toOptionType=' + this
									.toOptionType
							})
						} else if (this.toAddType == 4) {
							if (this.toOptionType == 1) {
								uni.reLaunch({
									url: '/pages/create/index?videoPath=' + this.videoPath + '&audioUrl=' +
										this.audioUrl + '&audioTitle=' + this.audioTitle
								})
							} else if (this.toOptionType == 2) {
								uni.redirectTo({
									url: '/pagesHome/audioList/index?videoPath=' + this.videoPath
								})
							} else if (this.toOptionType == 3) {
								uni.reLaunch({
									url: '/pagesMine/worksLibrary/index?current=1'
								})
							}
						} else if (this.toAddType == 5) {
							if (this.toOptionType == 1) {
								uni.reLaunch({
									url: '/pages/create/index?videoPath=' + this.videoPath + '&audioUrl=' +
										this.audioUrl + '&audioTitle=' + this.audioTitle
								})
							} else if (this.toOptionType == 2) {
								uni.redirectTo({
									url: '/pagesHome/audioList/index?videoPath=' + this.videoPath
								})
							} else if (this.toOptionType == 3) {
								uni.reLaunch({
									url: '/pagesMine/worksLibrary/index?current=1'
								})
							}
						}


					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}).catch(err => {
					this.isLoading = false;
					uni.hideLoading();
					console.log(err, 'err')
					uni.showToast({
						title: '出错了',
						icon: 'none'
					})
				})
			},
			addAudioToMine() {
				uni.showLoading({
					title: '上传中'
				})
				this.isLoading = true;
				tapeFile({
					uid: uni.getStorageSync("userId"),
					title: this.audioTitle,
					mp3: this.audioUrl
				}).then(res => {
					console.log(res, 'eeee')
					this.isLoading = false;
					uni.hideLoading();
					if (res.errno == 0) {
						console.log(this.videoPath, 'this.videoPath')
						this.audioId = res.data;
						if (this.toAddType == 1) {
							uni.switchTab({
								url: '/pages/mine/index?current=1'
							})
						} else if (this.toAddType == 2) {
							if (this.toOptionType == 1) {
								uni.reLaunch({
									url: '/pages/create/index?videoPath=' + this.videoPath + '&audioUrl=' +
										this.audioUrl + '&audioTitle=' + this.audioTitle + '&audioId=' +
										this.audioId
								})
							} else if (this.toOptionType == 2) {
								uni.redirectTo({
									url: '/pagesHome/audioList/index?videoPath=' + this.videoPath
								})
							} else if (this.toOptionType == 3) {
								uni.navigateBack({delta:uni.getStorageSync("gateback")+1})
								// uni.reLaunch({
								// 	url: '/pagesMine/worksLibrary/index?current=1'
								// })
							}
						} else if (this.toAddType == 3) {
							uni.redirectTo({
								url: '/pagesCreate/addAudioByText/index?videoPath=' + this.videoPath +
									'&clickoption=' + this.clickoption + '&toOptionType=' + this
									.toOptionType
							})
						} else if (this.toAddType == 4) {
							if (this.toOptionType == 1) {
								uni.reLaunch({
									url: '/pages/create/index?videoPath=' + this.videoPath + '&audioUrl=' +
										this.audioUrl + '&audioTitle=' + this.audioTitle + '&audioId=' +
										this.audioId
								})
							} else if (this.toOptionType == 2) {
								uni.redirectTo({
									url: '/pagesHome/audioList/index?videoPath=' + this.videoPath
								})
							} else if (this.toOptionType == 3) {
								uni.navigateBack({delta:uni.getStorageSync("gateback")})
								// uni.reLaunch({
								// 	url: '/pagesMine/worksLibrary/index?current=1'
								// })
							}
						} else if (this.toAddType == 5) {
							if (this.toOptionType == 1) {
								uni.reLaunch({
									url: '/pages/create/index?videoPath=' + this.videoPath + '&audioUrl=' +
										this.audioUrl + '&audioTitle=' + this.audioTitle + '&audioId=' +
										this.audioId
								})
							} else if (this.toOptionType == 2) {
								uni.redirectTo({
									url: '/pagesHome/audioList/index?videoPath=' + this.videoPath
								})
							} else if (this.toOptionType == 3) {
								uni.navigateBack({delta:uni.getStorageSync("gateback")})
								// uni.reLaunch({
								// 	url: '/pagesMine/worksLibrary/index?current=1'
								// })
							}
							// uni.reLaunch({
							// 	url: '/pagesCreate/addAudioByText/index?videoPath=' + this.videoPath + '&clickoption=' + this.clickoption + '&toOptionType=' + this.toOptionType
							// })
						}
			
			
					}else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 1000
						})
					}
				}).catch(err => {
					this.isLoading = false;
					uni.hideLoading();
				})
			},
			uploadAudioFile() {
				var _this = this;
				_this.isLoading = true;
				_this.$upload(_this.audioUrlTemp).then(res => {
					console.log(res, 'uploadImg')
					if (res.data.errno == 1) {
						uni.hideLoading();
						_this.audioUrl = res.data.img
						// _this.audioName = fileName
						console.log(_this.audioUrl, '上传音频')

						_this.showPop = false;

						// _this.addAudioToMine();
						if (_this.toAddType == 1 || _this.toAddType == 3) {
							_this.addTimbreToMine();
						} else {
							_this.addAudioToMine();
						}

					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}


				}).catch(err => {
					uni.hideLoading();
					console.log(err, 'err')

				})
			},
			uploadAudioFileNew() {
				var _this = this;
				_this.$uploadAudioNew(_this.audioUrlTemp).then(res => {
					console.log(res, 'uploadImg')
					if (res.data.errno == 1) {
						uni.hideLoading();
						_this.audioUrl = res.data.img
						// _this.audioName = fileName
						console.log(_this.audioUrl, '上传音频')

						_this.showPop = false;
						_this.addTimbreToMine();


					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}


				}).catch(err => {
					uni.hideLoading();
					console.log(err, 'err')

				})
			},
			uploadAudio() {
				// uni.showLoading({
				// 	title: '上传音频中'
				// })
				console.log(this.toAddType, '_this.toAddType')
				// return
				// if(this.toAddType == 1 || this.toAddType == 3){
				// 	this.uploadAudioFileNew();
				// }else {
				// 	this.uploadAudioFile();
				// }
				this.uploadAudioFile();

				// var _this = this;
				// _this.$upload(_this.audioUrlTemp).then(res => {
				// 	console.log(res, 'uploadImg')
				// 	if(res.data.errno == 1){
				// 		uni.hideLoading();
				// 		_this.audioUrl = res.data.img
				// 		// _this.audioName = fileName
				// 		console.log(_this.audioUrl, '上传音频')

				// 		_this.showPop = false;
				// 		if(_this.toAddType == 1 || _this.toAddType == 3){
				// 			_this.addTimbreToMine();
				// 		}else {
				// 			_this.addAudioToMine();
				// 		}

				// 		// uni.reLaunch({
				// 		// 	url: '/pages/create/index?audioName=' + fileName + '&audioUrl=' + _this.audioUrl
				// 		// })
				// 	}else {
				// 		uni.hideLoading();
				// 		uni.showToast({
				// 			title: res.data.message,
				// 			icon: 'none'
				// 		})
				// 	}


				// }).catch(err => {
				// 	uni.hideLoading();
				// 	console.log(err,'err')

				// })
			},
			// 提取音色
			getTiqu(url){
				uni.showLoading({
					title: '提取中',
					mask:true
				})
				MinorlanguagesTiqu({
					uid: uni.getStorageSync('userId'),
					voiceUrl:url,
					lan_id:this.timbreId,
					list_id:this.list_id
				}).then(res=>{
					uni.hideLoading()
					if(res.errno == 0){
						uni.showToast({
							title:"提取成功",
							icon:"none"
						})
						setTimeout(()=>{
							uni.navigateBack({
								delta:2,
							})
						},1000)
						console.log(res,"提取音色");
					}else {
						uni.showToast({
							title:res.msg,
							icon:"none"
						})
					}
					
					console.log(res,"提取音色");
				}).catch(err => {
					console.log(err, 'err')
					uni.hideLoading()
					uni.showToast({
						title: '提取失败',
						icon: 'none'
					})
				})
			}
		}
	}
</script>
<style lang="less" scoped>
	/deep/ .u-mode-center-box {
		background-color: rgba(0, 0, 0, 0) !important;
	}
</style>
<style>
	@import url(../../static/css/common.css);
	
	page {
		background-color: #111113;
	}
</style>
<style lang="scss" scoped>
	.mt-23-5 {
		margin-top: 47rpx;
	}

	.mt-29 {
		margin-top: 58rpx;
	}

	.ml-5-5 {
		margin-left: 11rpx;
	}

	.mt-23 {
		margin-top: 46rpx;
	}

	.mt-12-5 {
		margin-top: 25rpx;
	}

	.page {
		padding: 35rpx 20rpx 71rpx;
		background-color: #111113;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.image {
		margin-left: 42rpx;
		margin-right: 13rpx;
		width: 655rpx;
		height: 24rpx;
	}

	.image_2 {
		width: 20rpx;
		height: 35rpx;
	}

	.pos {
		position: absolute;
		left: 0;
		top: 50%;
		transform: translateY(-50%);
	}

	.text {
		color: #ffffff;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: 500;
		line-height: 34rpx;
	}

	.group {
		padding: 0 9rpx;
		width: 692rpx;
	}

	.textarea-class {
		/* height: 100%; */
		width: 100%;
		height: 40vh;
		/* font-size: 26rpx; */
		font-size: 32rpx;
		font-family: PingFang SC;
		color: #ffffff;
		line-height: 60rpx;
	}

	.section {
		padding: 52rpx 33rpx 36rpx;
		border-radius: 32rpx;
		// background-image: url('https://terminator.axu9.com/images/add-text-bg.png');
		background-size: 100% 100%;
		background-repeat: no-repeat;
	}

	.text_2 {
		color: #ffffff;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 500;
		line-height: 31rpx;
	}

	.font {
		font-size: 26rpx;
		font-family: PingFang SC;
		/* line-height: 80rpx; */
		color: #ffffff;
		margin-top: 20rpx;
		/* height: 60rpx; */
	}

	.font_1 {
		font-size: 26rpx;
		font-family: PingFang SC;
		color: #ffffff;
	}

	.section_2 {
		padding: 36rpx 4rpx 85rpx;
		background-color: #020f14;
		border-radius: 32rpx;
		border-left: solid 1rpx #8f9192;
		border-right: solid 1rpx #8f9192;
		border-top: solid 1rpx #8f9192;
		border-bottom: solid 1rpx #8f9192;
		width: 690rpx;
		height: 245rpx;
	}

	.image_3 {
		width: 25rpx;
		height: 31rpx;
	}

	.text_3 {
		color: #ffffff;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		line-height: 22rpx;
	}

	.image_4 {
		margin-right: 7rpx;
		width: 675rpx;
		height: 45rpx;
	}

	.group_2 {
		/* padding: 0 109rpx; */
		width: 60%;
	}

	.image_6 {
		border-radius: 34rpx;
		width: 108rpx;
		height: 68rpx;
	}

	.image_5 {
		width: 106rpx;
		height: 106rpx;
	}

	.image_7 {
		margin-right: 5rpx;
	}

	.text_4 {
		line-height: 25rpx;
	}

	// .popup {
	// 	// margin-right: 40rpx;
	// 	padding: 59rpx 28rpx 30rpx;
	// 	border-radius: 32rpx;
	// 	background-image: url('https://terminator.axu9.com/images/video-pop-bg.png');
	// 	background-size: 100% 100%;
	// 	background-repeat: no-repeat;
	// 	width: 615rpx;
	// 	// height: 616rpx;
	// }

	.title {
		font-size: 32rpx;
		font-family: PingFang SC;
		line-height: 31rpx;
		font-weight: 500;
		color: #ffffff;
	}

	.input-wrap {
		padding: 41rpx 0;
		border-radius: 16rpx;
		width: 542rpx;
		border: 1rpx solid #ffffff;
		margin-top: 35rpx;
	}

	.input-class {
		margin-left: 30rpx;
		color: #ffffff;
		font-size: 28rpx;
		font-family: PingFang SC;
		line-height: 26rpx;
	}

	.input-placeholder {
		/* margin-left: 30rpx; */
		color: #ffffff;
		font-size: 28rpx;
		font-family: PingFang SC;
		line-height: 26rpx;
	}

	.content {
		margin-left: 6rpx;
		color: #ffffff;
		font-size: 26rpx;
		font-family: PingFang SC;
		line-height: 54rpx;
		text-align: center;
		height: 270rpx;
		overflow-y: scroll;
	}

	.bottom {
		margin-top: 26rpx;
		width: 60%;
	}

	.text_agree {
		color: #ffffff;
		font-size: 22rpx;
		font-family: PingFang SC;
		line-height: 22rpx;
	}

	.bottom-btn {
		margin-top: 35rpx;
	}

	.agree-btn {
		padding: 34rpx 0;
		flex: 1 1 257rpx;
		border-radius: 16rpx;
		height: 102rpx;
		border-left: solid 2rpx #00e586;
		border-right: solid 2rpx #00e586;
		border-top: solid 2rpx #00e586;
		border-bottom: solid 2rpx #00e586;
	}

	.font-noagree {
		color: #00e586;
		font-size: 32rpx;
		font-family: PingFang SC;
		line-height: 31rpx;
		font-weight: 500;
	}

	.font-agree {
		color: #ffffff;
		font-size: 32rpx;
		font-family: PingFang SC;
		line-height: 31rpx;
		font-weight: 500;
	}

	.noagree-btn {
		margin-right: 5rpx;
		padding: 34rpx 0;
		flex: 1 1 257rpx;
		background-image: linear-gradient(90deg, $button-color-bg-lin-left 0%, $button-color-bg-lin-right 100%);
		border-radius: 16rpx;
		height: 100rpx;
	}


	.text-wrapper {
		width: 690rpx;
		height: 99rpx;
		padding: 34rpx 0;
		background-image: linear-gradient(90deg, $button-color-bg-lin-left 0%, $button-color-bg-lin-right 100%);
		border-radius: 50rpx;
	}
</style>